echo "Keystore name:"
read keystore
echo "Alias for key:"
read alias
echo "Keypass:"
read keypass
echo "Storepass:"
read storepass

keytool -genkeypair -alias $alias -keysize 1024 -keystore $keystore -storepass $storepass -keypass $keypass

keytool -list -keystore $keystore -storepass $storepass

echo "Generate Certificate Sign Request"
echo "Choose filename for CSR:"
read csrfilename
echo "Choose filename for CRT:"
read crtfilename

keytool -certreq -alias $alias -keypass $keypass -keystore $keystore -storepass $storepass -file $csrfilename

openssl x509 -req -in $csrfilename -CA ca.crt -CAkey ca.key -out $crtfilename -days 365 -CAcreateserial

keytool -importcert -alias ca_crt -keypass cakey -file ca.crt -keystore $keystore -storepass $storepass

keytool -importcert -alias $alias -keypass $keypass -file $crtfilename -keystore $keystore -storepass $storepass

keytool -list -v -keystore $keystore -storepass $storepass

keytool -list -keystore $keystore -storepass $storepass
